#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    map<int, int> mp;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
    }
    int cnt = 0;
    for(auto [k, v] : mp) {
        if(v == 1) cnt++;
    }
    int t = n - cnt;
    cout << t - 1 << ' ' << cnt / (t - 1) << endl;
}

signed main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}